/*public class Test {
    public static void main(String[] args) {
        Cat cat1 = new Cat();

    }
}
class Cat{
    String name;
    int age;
    void shout(){
        int a = 0;
        System.out.println("喵喵..........");
    }

}*/
//static操作符
/*
public class Test {
    public static void main(String[] args) {
     Student student1 = new Student();
     student1.name = "张三";
     student1.age = 10;
     student1.StuNum = "123";
     Student student2 = new Student();
        student2.name = "lisi";
        student2.age = 12;
        student2.StuNum = "12348";
       student1.grade = "1班";
      //  System.out.println(student2.grade);
      Student.shout();
      student1.shout();
    }
}
class Student{
    String StuNum ;
    String name;
    int age;
    static String grade;
public static void shout(){
    System.out.println("哈哈");
}

    public static void main(String[] args) {
        shout();
    }
*/
/*
public class Test {
    public static void main(String[] args) {
        Dog dog1 = new Dog();
        dog1.test();
    }
}
class Dog {
    String name;
    int age = 10;

    public static void shout() {
        System.out.println("汪汪..........");
    }
    public void test (){
        this.shout();
    }

}*/
//代码块
//普通代码块
/*
public class Test {
    public static void main(String[] args) {
            Animal animal = new Animal();
           */
/*Animal animal1= new Animal();*//*

        System.out.println(animal.name);
    }
}
class Animal{

    int age;
     public static String  sex;
    public static    void test1(){
        //普通代码块  ——普通代码块是定义在方法中的代码块，目的是为了区分变量作用域
        {
          int a = 10;
            System.out.println("执行了普通代码块");

        }
      //  System.out.println(a);

    }
 */
/*   public Animal(String name, int age) {
        this.name = name;
        this.age = age;
        System.out.println("执行了构造方法");
    }*//*

    //构造代码块 ——构造代码块不定义在方法中，成员方法平级
    //构造代码块在实例化对象时，会执行
    {
        this.name = "狗";
        this.age = 10;
       System.out.println("实例代码块执行了.........");

    }
  //静态代码块
    //前面阐述到，为静态成员变量赋值可以通过静态代码块：
  static {
         sex  =  "母";
      System.out.println("静态代码块执行了.....");

  }
    String name = "猫";


}
*/

public class Test {



    public static void main(String[] args) {
        Student student = new Student("zhangsan",10);

        System.out.println(student);
    }
}
class Student{
    String name ;
    int age ;

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }
}




















